home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Tool Chest / Development Platforms / Macintosh Common Lisp Related / interfaces / PInterface Translator / PInterfaces / StandardFile.p < prev    next >
Encoding:
Text File  |  1993-09-16  |  7.2 KB  |  247 lines  |  [TEXT/MPS ]

  1. {
  2. Created: Sunday, January 6, 1991 at 11:19 PM
  3.     StandardFile.p
  4.     Pascal Interface to the Macintosh Libraries
  5.  
  6.         Copyright Apple Computer, Inc.    1990
  7.         All rights reserved
  8.  
  9. }
  10.  
  11.  
  12. {$IFC UNDEFINED UsingIncludes}
  13. {$SETC UsingIncludes := 0}
  14. {$ENDC}
  15.  
  16. {$IFC NOT UsingIncludes}
  17.     UNIT StandardFile;
  18.     INTERFACE
  19. {$ENDC}
  20.  
  21. {$IFC UNDEFINED UsingStandardFile}
  22. {$SETC UsingStandardFile := 1}
  23.  
  24. {$I+}
  25. {$SETC StandardFileIncludes := UsingIncludes}
  26. {$SETC UsingIncludes := 1}
  27. {$IFC UNDEFINED UsingTypes}
  28. {$I $$Shell(PInterfaces)Types.p}
  29. {$ENDC}
  30. {$IFC UNDEFINED UsingDialogs}
  31. {$I $$Shell(PInterfaces)Dialogs.p}
  32. {$ENDC}
  33. {$IFC UNDEFINED UsingFiles}
  34. {$I $$Shell(PInterfaces)Files.p}
  35. {$ENDC}
  36. {$SETC UsingIncludes := StandardFileIncludes}
  37.  
  38. CONST
  39.  
  40. { resource IDs and item offsets of pre-7.0 dialogs }
  41. putDlgID = -3999;
  42. putSave = 1;
  43. putCancel = 2;
  44. putEject = 5;
  45. putDrive = 6;
  46. putName = 7;
  47.  
  48. getDlgID = -4000;
  49. getOpen = 1;
  50. getCancel = 3;
  51. getEject = 5;
  52. getDrive = 6;
  53. getNmList = 7;
  54. getScroll = 8;
  55.  
  56. { resource IDs and item offsets of 7.0 dialogs }
  57. sfPutDialogID = -6043;
  58. sfGetDialogID = -6042;
  59. sfItemOpenButton = 1;
  60. sfItemCancelButton = 2;
  61. sfItemBalloonHelp = 3;
  62. sfItemVolumeUser = 4;
  63. sfItemEjectButton = 5;
  64. sfItemDesktopButton = 6;
  65. sfItemFileListUser = 7;
  66. sfItemPopUpMenuUser = 8;
  67. sfItemDividerLinePict = 9;
  68. sfItemFileNameTextEdit = 10;
  69. sfItemPromptStaticText = 11;
  70. sfItemNewFolderUser = 12;
  71.  
  72.  
  73. { pseudo-item hits for use in DlgHook }
  74. sfHookFirstCall = -1;
  75. sfHookCharOffset = $1000;
  76. sfHookNullEvent = 100;
  77. sfHookRebuildList = 101;
  78. sfHookFolderPopUp = 102;
  79. sfHookOpenFolder = 103;
  80.  
  81.  
  82. { the following are only in system 7.0+ }
  83. sfHookOpenAlias = 104;
  84. sfHookGoToDesktop = 105;
  85. sfHookGoToAliasTarget = 106;
  86. sfHookGoToParent = 107;
  87. sfHookGoToNextDrive = 108;
  88. sfHookGoToPrevDrive = 109;
  89. sfHookChangeSelection = 110;
  90. sfHookSetActiveOffset = 200;
  91. sfHookLastCall = -2;
  92.  
  93. { the refcon field of the dialog record during a
  94.  modalfilter or dialoghook contains one of the following }
  95. sfMainDialogRefCon = 'stdf';
  96. sfNewFolderDialogRefCon = 'nfdr';
  97. sfReplaceDialogRefCon = 'rplc';
  98. sfStatWarnDialogRefCon = 'stat';
  99. sfLockWarnDialogRefCon = 'lock';
  100. sfErrorDialogRefCon = 'err ';
  101.  
  102. TYPE
  103. SFReply = RECORD
  104.     good: BOOLEAN;
  105.     copy: BOOLEAN;
  106.     fType: OSType;
  107.     vRefNum: INTEGER;
  108.     version: INTEGER;
  109.     fName: Str63;
  110.     END;
  111.  
  112. StandardFileReply = RECORD
  113.     sfGood: BOOLEAN;
  114.     sfReplacing: BOOLEAN;
  115.     sfType: OSType;
  116.     sfFile: FSSpec;
  117.     sfScript: ScriptCode;
  118.     sfFlags: INTEGER;
  119.     sfIsFolder: BOOLEAN;
  120.     sfIsVolume: BOOLEAN;
  121.     sfReserved1: LONGINT;
  122.     sfReserved2: INTEGER;
  123.     END;
  124.  
  125.  
  126. DlgHookProcPtr = ProcPtr;           { FUNCTION Hook(item: INTEGER; theDialog: DialogPtr): INTEGER; }
  127. FileFilterProcPtr = ProcPtr;        { FUNCTION FileFilter(PB: CInfoPBPtr): BOOLEAN; }
  128.  
  129. { the following also include an extra parameter of "your data pointer" }
  130. DlgHookYDProcPtr = ProcPtr;         { FUNCTION  Hook(item: INTEGER; theDialog: DialogPtr; yourDataPtr: Ptr): INTEGER; }
  131. ModalFilterYDProcPtr = ProcPtr;     { FUNCTION  Filter(theDialog: DialogPtr; VAR theEvent: EventRecord; VAR itemHit: INTEGER; yourDataPtr: Ptr): BOOLEAN; }
  132. FileFilterYDProcPtr = ProcPtr;      { FUNCTION  FileFilter(PB: CInfoPBPtr; yourDataPtr: Ptr): BOOLEAN; }
  133. ActivateYDProcPtr = ProcPtr;        { PROCEDURE Activate(theDialog; DialogPtr; itemNo: INTEGER; activating: BOOLEAN; yourDataPtr: Ptr); }
  134.  
  135. SFTypeList = ARRAY [0..3] OF OSType;
  136.  
  137. PROCEDURE SFPutFile(where: Point;
  138.                     prompt: Str255;
  139.                     origName: Str255;
  140.                     dlgHook: DlgHookProcPtr;
  141.                     VAR reply: SFReply);
  142.     INLINE $3F3C,$0001,$A9EA;
  143.  
  144. PROCEDURE SFGetFile(where: Point;
  145.                     prompt: Str255;
  146.                     fileFilter: FileFilterProcPtr;
  147.                     numTypes: INTEGER;
  148.                     typeList: SFTypeList;
  149.                     dlgHook: DlgHookProcPtr;
  150.                     VAR reply: SFReply);
  151.     INLINE $3F3C,$0002,$A9EA;
  152.  
  153. PROCEDURE SFPPutFile(where: Point;
  154.                      prompt: Str255;
  155.                      origName: Str255;
  156.                      dlgHook: DlgHookProcPtr;
  157.                      VAR reply: SFReply;
  158.                      dlgID: INTEGER;
  159.                      filterProc: ModalFilterProcPtr);
  160.     INLINE $3F3C,$0003,$A9EA;
  161.  
  162. PROCEDURE SFPGetFile(where: Point;
  163.                      prompt: Str255;
  164.                      fileFilter: FileFilterProcPtr;
  165.                      numTypes: INTEGER;
  166.                      typeList: SFTypeList;
  167.                      dlgHook: DlgHookProcPtr;
  168.                      VAR reply: SFReply;
  169.                      dlgID: INTEGER;
  170.                      filterProc: ModalFilterProcPtr);
  171.     INLINE $3F3C,$0004,$A9EA;
  172.  
  173. PROCEDURE StandardPutFile(prompt: Str255;
  174.                           defaultName: Str255;
  175.                           VAR reply: StandardFileReply);
  176.     INLINE $3F3C,$0005,$A9EA;
  177.  
  178. PROCEDURE StandardGetFile(fileFilter: FileFilterProcPtr;
  179.                           numTypes: INTEGER;
  180.                           typeList: SFTypeList;
  181.                           VAR reply: StandardFileReply);
  182.     INLINE $3F3C,$0006,$A9EA;
  183.  
  184. PROCEDURE CustomPutFile(prompt: Str255;
  185.                         defaultName: Str255;
  186.                         VAR reply: StandardFileReply;
  187.                         dlgID: INTEGER;
  188.                         where: Point;
  189.                         dlgHook: DlgHookYDProcPtr;
  190.                         filterProc: ModalFilterYDProcPtr;
  191.                         activeList: Ptr;
  192.                         activateProc: ActivateYDProcPtr;
  193.                         yourDataPtr: UNIV Ptr);
  194.     INLINE $3F3C,$0007,$A9EA;
  195.  
  196. PROCEDURE CustomGetFile(fileFilter: FileFilterYDProcPtr;
  197.                         numTypes: INTEGER;
  198.                         typeList: SFTypeList;
  199.                         VAR reply: StandardFileReply;
  200.                         dlgID: INTEGER;
  201.                         where: Point;
  202.                         dlgHook: DlgHookYDProcPtr;
  203.                         filterProc: ModalFilterYDProcPtr;
  204.                         activeList: Ptr;
  205.                         activateProc: ActivateYDProcPtr;
  206.                         yourDataPtr: UNIV Ptr);
  207.     INLINE $3F3C,$0008,$A9EA;
  208.  
  209.  
  210.     New StandardFile routine comments:
  211.  
  212.     activeList is pointer to array of integer (16-bits).
  213.     first integer is length of list.
  214.     following integers are possible activatable DITL items, in
  215.     the order that the tab key will cycle through.  The first
  216.     in the list is the item made active when dialog is first shown.
  217.  
  218.     activateProc is a pointer to a procedure like:
  219.  
  220.         PROCEDURE MyActivateProc(theDialog:     DialogPtr;
  221.                                  itemNo:        INTEGER;
  222.                                  activating:    BOOLEAN;
  223.                                  yourDataPtr:    Ptr);
  224.  
  225.     The activateProc is called with activating=FALSE on the itemNo
  226.     about to deactivate then with activating=TRUE on the itemNo
  227.     about to become the active item. (like activate event)
  228.  
  229.     yourDataPtr is a nice little extra that makes life easier without
  230.     globals.  CustomGetFile & CustomPPutFile when calling any of their
  231.     call back procedures, pushes the extra parameter of yourDataPtr on
  232.     the stack.
  233.  
  234.     In addition the filterProc in CustomGetFile & CustomPPutFile is called
  235.     before before SF does any mapping, instead of after.
  236.  }
  237.  
  238.  
  239.  
  240. {$ENDC}    { UsingStandardFile }
  241.  
  242. {$IFC NOT UsingIncludes}
  243.     END.
  244. {$ENDC}
  245.  
  246.